package cn.aspart.aop.config;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
@Component
@Order(2)
public class LogAspect {

    @Pointcut("execution(* cn.aspart.aop.service.*.*(..))")
    private void logPointcut(){

    }

    @Before("logPointcut()")
    public void before(JoinPoint joinPoint) {
        log.info("before method {}, log this", joinPoint.getSignature().getName());
    }

    @After("logPointcut()")
    public void after(JoinPoint joinPoint) {
        log.info("after method {}, log this", joinPoint.getSignature().getName());
    }

    @AfterReturning("logPointcut()")
    public void afterReturning(JoinPoint joinPoint) {
        log.info("after returning method {}, log this", joinPoint.getSignature().getName());
    }

}
